{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "import datetime\n",
    "import hashlib\n",
    "import rabbitpy"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "with rabbitpy.Connection() as connection:                              #A\n",
    "    with connection.channel() as channel:                              #B\n",
    "        for iteration in range(100000):                                #C\n",
    "            timestamp = datetime.datetime.now().isoformat()            #D\n",
    "            hash_value = hashlib.md5('%s:%s' % (timestamp, iteration)) #E\n",
    "            msg = rabbitpy.Message(channel, 'Image # %i' % iteration,  #F\n",
    "                                   {'headers': \n",
    "                                     {'image-hash': str(hash_value.hexdigest())}},\n",
    "                                    opinionated=True)\n",
    "            msg.publish('image-storage')                               #G"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 2",
   "language": "python",
   "name": "python2"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 2
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython2",
   "version": "2.7.6"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 0
}
